<template>
  <div class="userNameFatch" @click.stop="isUser">
    <el-col class="userName flex4">
      <div class="demo-basic--circle">
        <div class="block">
          <el-avatar :size="50" :src="circleUrl" />
        </div>
      </div>
      <div class="name">{{ "不太聪明" }}</div>
    </el-col>
  </div>
  <div class="messageList" v-if="isShow">
      <div class="messageListSon">账号:666366</div>
      <div class="messageListSon">昵称:不太聪明</div>
      <div class="messageListSon" @click="LeaveUser">退出登录</div>
    </div>
</template>

<script setup lang="ts">
import { reactive, toRefs ,ref,onMounted} from "vue";
import {useRouter } from "vue-router";
const state = reactive({
  circleUrl:
    "https://ts1.cn.mm.bing.net/th/id/R-C.451eb4f3577bcb3980c9eea8f2635482?rik=Jg08MZs0aNN0mg&riu=http%3a%2f%2fm.imeitou.com%2fuploads%2fallimg%2f2018082817%2fuulzgsar5vy.jpg&ehk=Kg78F1rZG%2bwBxsyzAW%2fsZSrvUD97WDrNhwpxYWWvmOg%3d&risl=&pid=ImgRaw&r=0",
});
const { circleUrl } = toRefs(state);

// 退出账户
let router=useRouter()
let LeaveUser=()=>{
  // router.push()
  
}
// 点击个人资料信息框显示判断
let isShow=ref(false)
let isUser=()=>{
  isShow.value=!isShow.value;
}
// 点击别处收回
onMounted(()=>{
document.addEventListener('click',(e)=>{
if(e.target){
  isShow.value=false
}
})
})
</script>

<style scoped lang="scss">
.userNameFatch {
  position: relative;
  cursor: pointer;
}
.userName {
  margin-right: 60px;
  width: 200px;
  .name {
    width: 120px;
    margin-left: 20px;
  }
}
.demo-basic--circle {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.messageList {
  width: 200px;
  height: 100px;
  background-color:#3c3737;
  position: absolute;
  right: 90px;
  top: 70px;
  cursor: pointer;
  .messageListSon{
    height: 30px;
    text-align: center;
    line-height: 30px;
  }
  .messageListSon:hover{
    background-color:#6c5252;
  }
}
</style>
